package com.hy.erp.inventory.service;

import java.util.List ;

import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
import org.jboss.seam.async.Schedule ;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.IDisposalWayDao;
import com.hy.erp.inventory.pojo.DisposalWay;
import com.hy.erp.inventory.pojo.interfaces.IDisposalWay;
import com.hy.erp.inventory.service.interfaces.IDisposalWayService;
/**
 * 
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-11-13；时间：下午01:05:00</li>
 * <li>类型名称：DisposalWayService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@Name("disposalWayService")
@ Scope ( ScopeType.SESSION )
@ Stateless
public class DisposalWayService
								extends
								AbstractBusinessService < IDisposalWay >
																		implements
																		IDisposalWayService
{

	
	/**
	 * <ul>
	 * <li>开发作者：汤莉</li>
	 * <li>设计日期：2010-11-13；时间：下午01:06:45</li>
	 * <li>字段类型：long；字段名称：serialVersionUID</li>
	 * <li>设计目的：</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 */
	private static final long	serialVersionUID	=
														7910268364388075337L ;

	public DisposalWayService(){}
	
	@ Override
	public boolean addDisposalWay (
									DisposalWay type )
	{
		if(type==null){
			return true ;
		}
		else
		{
			IDisposalWayDao dao=( IDisposalWayDao ) this.getDao ( IDisposalWay.class );
			IDisposalWay type2=type;
			return dao.persist ( type2 );
		}
	}

	@ Override
	public Integer removeDisposalWay (
										String [ ] Ids )
	{
		if ( ( null == Ids )
			     || ( Ids.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{
				IDisposalWayDao dao=( IDisposalWayDao ) this.getDao ( IDisposalWay.class );
				return dao.remove ( Ids );
			}
	}

	@ SuppressWarnings ( "unused" )
	@ Override
	public boolean modifyDisposalWay (
										DisposalWay type )
	{
		if ( ( null == type ) || ( null == type.getIdentifier ( ) ))
		{
			return true;
		}
		else
		{
			IDisposalWayDao dao=( IDisposalWayDao ) this.getDao ( IDisposalWay.class );
			IDisposalWay type2=type;
			
			if ( null == type2 )
			{
				throw new ArchitectureFoundationException (
				                                            "修改用户实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}
			return (dao.merge ( type2 )!=null) ;
		}
	}

	@ Override
	public String [ ] addDisposalWay (
										Object [ ] types )
	{
		if ( null == types)
		{
			return null ;
		}
		
		else
		{
			

			IDisposalWayDao dao=( IDisposalWayDao ) this.getDao ( IDisposalWay.class );
			DisposalWay[] disposalWays=new DisposalWay[types.length];
			for ( int i =
							0 ; i < types.length ; i ++ )
			{
				DisposalWay way=( DisposalWay ) types[i];
				disposalWays[i]=way;
			}
			
			return dao.persist ( disposalWays );
		}
	}

	@ Override
	public List < IDisposalWay > getDisposalWayById (
														String [ ] Ids )
	{
		if ( ( null == Ids )
			     || ( Ids.length == 0 ) )
			{
				return null ;
			}
			else
			{
				IDisposalWayDao dao=( IDisposalWayDao ) this.getDao ( IDisposalWay.class );
				
	                                        
				return dao.findByIdentifier ( Ids );
				
			}
	}


	@ Override
	public List < IDisposalWay > getAllDisposalWay ( )
	{
		IDisposalWayDao dao=( IDisposalWayDao ) this.getDao ( IDisposalWay.class );
		
		return dao.find ( ) ;
	}

	@ Override
	public String [ ] modifyDisposalWay (
											Object [ ] types )
	{

		if ( null == types)
		{
			return null ;
		}
		
		else
		{
			

			IDisposalWayDao dao=( IDisposalWayDao ) this.getDao ( IDisposalWay.class );
			DisposalWay[] disposalWays=new DisposalWay[types.length];
			for ( int i =
							0 ; i < types.length ; i ++ )
			{
				DisposalWay way=( DisposalWay ) types[i];
				disposalWays[i]=way;
			}
			
			return dao.merge ( disposalWays );
		}
	
	}

}
